export default {
  state: {
    ruleArr: [
      { id: 1, value: 1, label: "按工资薪金计税" },
      { id: 2, value: 2, label: "按劳务报酬计税", isHide: true },
    ],
    standardFormula: [], // 标准公式
    companyList: [], // 子公司列表
    userList: [], // 用户列表
    cityList: [], // 省市列表
    bankList: [], // 银行列表
    accountRouterData: {}, // 社保台账跨页面传递的参数
    payrollRouteData: { //代发工资列表跨页面传参
      name: 'xxxx',
      createTime: '',
      taxYear: new Date().getFullYear(),
      taxMonth: new Date().getMonth() + 1,
      subId: '',
    },
    grantPayslipRouteData: {
      userList: []
    }

  },
  getters: {

    /** 获取type */
    getTypes: (state) => (item) => {
      const columnPy = item.namePy;
      const itemPy = item.titlePy;
      if(itemPy == 'qingjiakoukuan') return state.standardFormula.filter(item => item.itemPy == itemPy );
      const arr = state.standardFormula.filter(item => item.itemPy == itemPy && item.columnPy == columnPy);
      console.log(columnPy, itemPy, arr, state.standardFormula);
      return arr;
    },
  },
  mutations: {

    /** 设置用户列表 */
    SET_UESR_LEST: (state, list) => {
      state.userList = list;
    },

    /** 设置子公司列表 */
    SET_CONPANY_LIST: (state, list) => {
      state.companyList = list;
    },

    /** 设置省市列表 */
    SET_CITY_LIST: (state, list) => {
      state.cityList = list;
    },

    /** 设置银行列表 */
    SET_BANK_LIST: (state, list) => {
      state.bankList = list;
    },

    /** 台账数据 */
    SET_ACCOUNT_ROUTER_DATA: (state, data) => {
      state.accountRouterData = data;
    },

    /** 代发工资列表项数据 */
    SET_PAYROLL_ROUTE_DATA: (state, data) => {
      state.payrollRouteData = data;
    },

    /** 设置标准公式下拉内容 */
    SET_STANDARD_FORMULA: (state, data) => {
      state.standardFormula = data;
    },

    // grantPayslipRouteData
    SET_GRANT_PAYSLIP_ROUTE_DATA: (state, data) => {
      state.grantPayslipRouteData = data;
    }
  },
  actions: {

    /** 设置用户列表 */
    setUserList({ commit }, list) {
      commit("SET_UESR_LEST", list);
    },

    /** 设置子公司列表 */
    setCompanyList({ commit }, list) {
      commit("SET_CONPANY_LIST", list);
    },

    /** 设置省市列表 */
    setCityList({ commit }, list) {
      commit("SET_CITY_LIST", list);
    },

    /** 设置银行列表 */
    setBankList({ commit }, list) {
      commit("SET_BANK_LIST", list);
    },

    /** 设置标准公式下拉内容 */
    setStandardFormula({ commit }, list) {
      commit("SET_STANDARD_FORMULA", list);
    }
  },
};
